package org.example.springboot.rest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class RestApp {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.build();
    }

    @Bean
    public User getUser(RestTemplate restTemplate) {
        User user = restTemplate.getForObject("http://localhost:8080/user/1", User.class);
        return user;
    }

    public static void main(String[] args) {
        SpringApplication.run(RestApp.class, args);
    }
}
